<template>
    <div class="nav-bar">
        <div class="l">
            <img src="../assets/images/navbar/fanhui.png" alt="" @click="$router.go(-1)" v-show="showBack" />
        </div>
        <p>{{ navTitle }}</p>
        <div class="r">
            <img src="../assets/images/navbar/fanhuishouye.png" v-if="showBackHome" />
            <div class="sort-box" v-if="ifSort">
                <span>排序</span>
                <img src="../assets/images/newscenter/排序.png" alt="" />
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            navTitle: '',
            showBack: false,
            showBackHome: true,
            ifSort: false,
        };
    },

    watch: {
        $route(newPath) {
            this.navTitle = newPath.meta.subTitle;
            this.showBack = newPath.meta.showBack;
            this.showBackHome = newPath.meta.showBackHome;
            this.ifSort = newPath.meta.ifSort;
            // switch (newPath.path) {
            //     case '/myclients':
            //         this.navTitle = '我的客户';
            //         this.showBack = true;
            //         this.showBackHome = true;
            //         this.ifSort = false;
            //         break;
            //     case '/customer':
            //         this.navTitle = '客户关怀';
            //         this.showBack = true;
            //         this.showBackHome = true;
            //         this.ifSort = false;
            //         break;
            // }
        },
    },
};
</script>

<style lang="less" scoped>
.nav-bar {
    width: 100%;
    height: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.25rem;
    box-sizing: border-box;
    background-color: #003399;
    overflow: hidden;
    position: fixed;
    left: 0;
    top: 0;
    .l,
    .r {
        height: 50%;
        img {
            height: 100%;
        }
    }
    .r {
        .sort-box {
            height: 100%;
            display: flex;
            align-items: center;
            span {
                color: #fff;
                margin-right: 0.1rem;
            }
            img {
                height: 80%;
            }
        }
    }
    p {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        color: #fff;
        font-size: 0.32rem;
    }
}
</style>
